﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Odbc;
using System.Text;
using StandardDAC.Base;

namespace StandardDAC.ODBC {
    public class OdbcColumn : DBColumn, IComparable<OdbcColumn> {
        short parameterOrder;

        public short ParameterOrder {
            get { return parameterOrder; }
            set { parameterOrder = value; }
        }

        public OdbcColumn(string name, OdbcType dbType, short parameterOrder)
            : base(name, dbType) {
            this.parameterOrder = parameterOrder;
        }

        public OdbcColumn(string name, OdbcType dbType, object nullValue, short parameterOrder)
            : base(name, dbType, nullValue) {
            this.parameterOrder = parameterOrder;
        }

        public OdbcColumn(string name, OdbcType dbType, object nullValue, bool isPrimaryKey, short parameterOrder)
            : base(name, dbType, nullValue, isPrimaryKey) {
            this.parameterOrder = parameterOrder;
        }
        public OdbcColumn(string name, OdbcType dbType, object nullValue, bool isPrimaryKey, short parameterOrder, bool isIdentity)
            : base(name, dbType, nullValue, isPrimaryKey, isIdentity) {
            this.parameterOrder = parameterOrder;
        }


        #region IComparable<OdbcColumn> Members

        public int CompareTo(OdbcColumn other) {
            return this.parameterOrder.CompareTo(other.ParameterOrder);
        }

        #endregion
    }

    public class StringOdbcColumn : OdbcColumn {
        public StringOdbcColumn(string name, short parameterOrder) : base(name, OdbcType.VarChar, parameterOrder) { }
        public StringOdbcColumn(string name, object nullValue, short parameterOrder) : base(name, OdbcType.VarChar, nullValue, parameterOrder) { }
    }
    public class PKOdbcColumn : OdbcColumn {
        public PKOdbcColumn(string name, short parameterOrder) : base(name, OdbcType.Int, null, true, parameterOrder) { }
        public PKOdbcColumn(string name, object nullValue, short parameterOrder) : base(name, OdbcType.Int, nullValue, true, parameterOrder) { }
        public PKOdbcColumn(string name, OdbcType dbType, object nullValue, short parameterOrder) : base(name, dbType, nullValue, true, parameterOrder) { }

        public PKOdbcColumn(string name, short parameterOrder, bool isIdentity) : base(name, OdbcType.Int, null, true, parameterOrder, isIdentity) { }
        public PKOdbcColumn(string name, object nullValue, short parameterOrder, bool isIdentity) : base(name, OdbcType.Int, nullValue, true, parameterOrder, isIdentity) { }
        public PKOdbcColumn(string name, OdbcType dbType, object nullValue, short parameterOrder, bool isIdentity) : base(name, dbType, nullValue, true, parameterOrder, isIdentity) { }
    }
    public class IdentityNotPKOdbcColumn : OdbcColumn {
        public IdentityNotPKOdbcColumn(string name, short parameterOrder) : base(name, OdbcType.Int, null, false, parameterOrder, true) { }
        public IdentityNotPKOdbcColumn(string name, object nullValue, short parameterOrder) : base(name, OdbcType.Int, nullValue, false, parameterOrder, true) { }
        public IdentityNotPKOdbcColumn(string name, OdbcType dbType, object nullValue, short parameterOrder) : base(name, dbType, nullValue, false, parameterOrder, true) { }
    }
}
